<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>只响应自身事件</title>
    <style>
        .box1 {
            width: 600px;
            height: 600px;
            background-color: red;
        }

        .box2 {
            width: 400px;
            height: 400px;
            background-color: chocolate;
        }

        .box3 {
            width: 200px;
            height: 200px;
            background-color: green;
        }

    </style>
</head>
<body>
<div id="app">
    <div class="box1" @click="box1Clicked">
        <div class="box2" @click="box2Clicked">
            <div class="box3" @click="box3Clicked">
            </div>
        </div>
    </div>

    <hr>
    <!-- 目标：点击 box3， box2 内容不进行输出。即 box2 只响应自身点击   -->

    <div class="box1" @click="box1Clicked">
        <div class="box2" @click.self="box2Clicked">
            <div class="box3" @click="box3Clicked">
            </div>
        </div>
    </div>

</div>

<script type="module">
    import {createApp} from "../../../js/vue.esm-browser.js";

    let app = createApp(
        {
            setup() {
                function box1Clicked() {
                    console.log("box1 clicked");
                }

                function box2Clicked() {
                    console.log("box2 clicked");
                }

                function box3Clicked() {
                    console.log("box3 clicked");
                }

                return {
                    box1Clicked, box2Clicked, box3Clicked,
                }
            }
        }
    );

    app.mount("#app")
</script>
</body>
</html>